<template>
	<view class="content">
		<view url="/page_other/policy/detail" class="btn">
			完善信息，为您精准匹配政策
		</view>

		<view class="middle">
			<view class="article-list">

				<view class="block">
					<view class="title">1、请问您的身份？</view>
					<view class="rado">
						<radio-group @change="changeRadioStudent">
							<label v-for="item in student" :key="item.id" style="margin-right: 20rpx;">
								<radio :value="item.id" :checked="item.id==studentKey" />{{item.data}}
							</label>
						</radio-group>
					</view>
				</view>
				<view class="block">
					<view class="title">2、请问您的毕业信息？</view>
					<!-- <input v-model="schoolName" name="shool" class="search" type="text" maxlength="30"
					placeholder="  请输入毕业院校" placeholder-class="inputPlaceholder" confirm-type="search" /> -->

					<input v-model="major" name="shool" class="search" type="text" maxlength="30"
						placeholder="  请输入毕业专业" placeholder-class="inputPlaceholder" confirm-type="search" />

					<view class="search">
						<picker style="line-height: 76rpx;color:#A0A0A0;margin-left: 25rpx;" @change="examinationType"
							:range="educationTypeArray" range-key="data" :value="educationTypeIndex">
							{{educationTypeArrayType}}
							<text style="float: right;padding-right: 30rpx;">▼</text></label>
						</picker>
					</view>

				</view>
				<view class="block">
					<view class="title">3、请问您的需求是什么？</view>
					<view class="rado">
						<radio-group @change="changeRadioWork">
							<label v-for="item in workType" :key="item.id" style="margin-right: 20rpx;">
								<radio :value="item.id" :checked="item.id==workKey" />{{item.data}}
							</label>
						</radio-group>
					</view>
				</view>
				<view class="block">
					<view class="title">4、请问您是否具有专业技术职称？</view>

					<view class="search">
						<picker style="line-height: 76rpx;color:#A0A0A0;" @change="titleType" :range="titleTypeArray">
							<label style="padding-left: 30rpx;">{{ titleTypeArrayType }}</label>
							<text style="float: right;padding-right: 30rpx;">▼</text>
						</picker>
					</view>

				</view>
				<view class="block">
					<view class="title">5、请问您是否具有职业资格证书？</view>

					<view class="search">
						<picker style="line-height: 76rpx;color:#A0A0A0;" @change="seniorityType"
							:range="seniorityTypeArray">
							<label style="padding-left: 30rpx;">{{ seniorityTypeArrayType }}</label>
							<text style="float: right;padding-right: 30rpx;">▼</text>
						</picker>
					</view>

				</view>
				<view class="block" style="border-bottom: 0px">
					<view class="title">6、请选择您的研究工作领域？</view>
					<view class="search">
						<picker style="line-height: 76rpx;color:#A0A0A0;margin-left: 25rpx;" @change="fieldType"
							:range="fieldTypeArray" range-key="data" :value="fieldTypeIndex">{{fieldTypeArrayType}}
							<text style="float: right;padding-right: 30rpx;">▼</text></label>
						</picker>
					</view>

				</view>
			</view>
		</view>
		<view @click="addUserPolicyInfo" class="btn2" style>
			一键匹配
		</view>
	</view>
</template>

<script>
	import {
		getEducation
	} from '@/api/config.js';
	import {
		addUserPolicyInfoApi
	} from '@/api/userPolicyInfo.js';
	import {
		getIndustry as getIndustryApi
	} from '@/api/config.js';
	export default {
		data() {
			return {
				addressKey: 0,
				studentKey: 0,
				student: [{
					id: 1,
					data: '应届生'
				}, {
					id: 2,
					data: '非应届生'
				}],
				educationTypeArray: ['请选择', '高中', '大专', '本科', '研究生'],
				educationTypeIndex: -1,
				educationTypeArrayType: '请选择学历',
				workKey: 0,
				workType: [{
					id: 1,
					data: '就业'
				}, {
					id: 2,
					data: '创业'
				}],
				titleTypeArray: ['请选择', '是', '否'],
				titleTypeIndex: -1,
				titleTypeArrayType: '请选择',
				seniorityTypeArray: ['请选择', '是', '否'],
				seniorityTypeIndex: -1,
				seniorityTypeArrayType: '请选择',
				fieldTypeArray: ['请选择', '软件', '硬件', '汽车', '航天'],
				fieldTypeIndex: -1,
				fieldTypeArrayType: '请选择',
				schoolName: '',
				major: '',


			}
		},
		methods: {

			titleType(e) {
				this.titleTypeIndex = e.target.value;
				this.titleTypeArrayType = this.titleTypeArray[this.titleTypeIndex];
			},
			seniorityType(e) {
				this.seniorityTypeIndex = e.target.value;
				this.seniorityTypeArrayType = this.seniorityTypeArray[this.seniorityTypeIndex];
			},
			fieldType(e) {
				this.fieldTypeIndex = e.target.value;
				this.fieldTypeArrayType = this.fieldTypeArray[this.fieldTypeIndex].data;
			},
			getEducationList() {
				getEducation().then((res) => {
						this.educationTypeArray = res ?? [];
				}).catch((res) => {
					console.log(res)
				})
			},
			getIndustry() {
				getIndustryApi().then((res) => {
						this.fieldTypeArray = res ?? [];
				}).catch((res) => {
					console.log(res)
				})
			},
			examinationType(e) {
				this.educationTypeIndex = e.target.value;
				this.educationTypeArrayType = this.educationTypeArray[this.educationTypeIndex].data;
			},
			changeRadioAddress(e) {
				this.addressKey = e.target.value;
			},
			changeRadioStudent(e) {
				this.studentKey = e.target.value;
			},
			changeRadioWork(e) {
				this.workKey = e.target.value;
			},

			addUserPolicyInfo() {
				if (this.studentKey < 1) {
					this.showToast('请选择您的身份！')
					return false
				}

				// if (this.schoolName == null || this.schoolName == '') {
				// 	this.utils.showToast('请填写您的学校！')
				// 	return false
				// }
				if (this.major == null || this.major == '') {
					this.showToast('请填写您的专业！')
					return false
				}
				if (this.educationTypeIndex < 0) {
					this.showToast('请选择您的学历！')
					return false
				} else {
					this.educationTypeIndex = this.educationTypeIndex * 1 + 1;
				}
				if (this.workKey < 1) {
					this.showToast('请选择您的需求！')
					return false
				}
				if (this.titleTypeIndex < 0) {
					this.showToast('请选择您是否具有专业技术职称！')
					return false
				}
				if (this.seniorityTypeIndex < 0) {
					this.showToast('请选择您是否具有职业资格证书！')
					return false
				}
				if (this.fieldTypeIndex < 0) {
					this.showToast('请选择您的研究领域！')
					return false
				} else {
					this.fieldTypeIndex = this.fieldTypeIndex * 1 + 1;
				}

				addUserPolicyInfoApi({
					seat: this.addressKey,
					identity: this.studentKey,
					schoolName: this.schoolName,
					major: this.major,
					education: this.educationTypeIndex,
					workingCondition: this.workKey,
					qualificationsState: this.seniorityTypeIndex,
					titleState: this.titleTypeIndex,
					industry: this.fieldTypeIndex
				}).then((res) => {
						uni.navigateTo({
							url: '/page_other/policy/detail?type=1'
						})
					
				}).catch((res) => {
					console.log(res)
				})
			},

		},
		onLoad() {
			this.getEducationList();
			this.getIndustry();
		},
	}
</script>

<style lang="scss">
	.content {
		padding: 30rpx;
		background-color: #FAFAFA;
		width: 100%;
		height: 100%;
		background-repeat: no-repeat;
		background-size: 100%;

		.btn {
			width: 240px;
			height: 60rpx;
			line-height: 58rpx;
			border-radius: 40rpx;
			text-align: center;
			color: #fff;
			background-color: #ff7626;
			font-size: 28rpx;
			margin-left: 14%;
			margin-bottom: 30rpx;
		}

		.btn2 {
			width: 240px;
			height: 80rpx;
			line-height: 76rpx;
			border-radius: 40rpx;
			text-align: center;
			color: #fff;
			background-color: #ff7626;
			font-size: 32rpx;
			margin-left: 14%;
			margin-bottom: 30rpx;
			margin-top: 30rpx;
		}

		.middle {
			background-color: #FFFFFF;
			border-radius: 15rpx;
			border-bottom: 1px solid #FAFAFA;

			.article-list {
				width: 100%;
				display: flex;
				flex-direction: column;
				padding: 20rpx;

				.title {
					font-size: 30rpx;
					font-weight: bold;
				}

				.rado {
					margin: 30rpx 0;
				}

				.block {
					border-bottom: 1px solid #e0d6d6;
					padding-top: 30rpx;

					.search {
						width: 100%;
						height: 70rpx;
						margin: 30rpx 0;
						font-size: 28rpx;
						background: #F3F3F3;
						border-radius: 50rpx;
						padding: 0 6rpx;
					}
				}



			}
		}

	}
</style>
